package net.demo.demo3;

import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;
import java.util.Scanner;

public class TcpClient {
    public static void main(String[] args) throws IOException {
        //创建socket对象
        Socket socket = new Socket("127.0.0.1", 10001);
        //获取输入流
        OutputStream os =socket.getOutputStream();
        //写入数据,多次发送
        Scanner sc=new Scanner(System.in);
        while (true){
            System.out.println("输入:");
            String s = sc.nextLine();
            if ("886".equals(s)){
                break;
            }
            byte[] bytes = s.getBytes();
            os.write(bytes);
        }


        os.close();
        socket.close();
    }
}
